package tech.aistar.day02;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 本类功能:转发
 *
 * @author cxylk
 * @date 2020/9/16 17:41
 */
@WebServlet(urlPatterns = "/day02/forward/from")
public class ForwardAction extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setAttribute("uname","tom");

        //转发的语法
        //req.getRequestDispatcher("/day02/forward/to").forward(req,resp);

        //重定向的语法
        //1.将新的Url地址响应返回给client
        resp.sendRedirect("/lk/day02/forward/to");
    }
}
